#include <mm32f0120.h>
#include "MM_Delay.h"


volatile uint32_t MM_DelayTick;

void MM_InitDelay(void)
{
    RCC_ClocksTypeDef RCC_Clocks;

    RCC_GetClocksFreq(&RCC_Clocks);

    if (SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000))
    {
        while (1)
        {
        }
    }

    NVIC_SetPriority(SysTick_IRQn, 0x0);
}


void MM_DelayMS(uint32_t Millisecond)
{
	MM_DelayTick = Millisecond;

	while (0 != MM_DelayTick)
	{
	}
}

void SysTick_Handler(void)
{
    if (0 != MM_DelayTick)
    {
        MM_DelayTick--;
    }
}